home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
PET
/
S-Super PET
/
(s)t4.d64
/
DIRECTORY.ASM
< prev
next >
Wrap
Assembly Source File
|
2009-01-18
|
5KB
|
125 lines
;Program to get directories from the Waterloo micromenu
;By Eric Brandon
;Version 1.10 09/06/82
xref putchar_
xref getchar_
xref getrec_
xref tbreak_
xref putnl_
xref diropenf_
xref dirreadf_
xref dirclose_
xref errorf_
out equ $ff80 ;Micro-menu jump address
buffer equ $2000 ;buffer for directory entry
drive equ $3000 ;drive number entry buffer
dirblock equ $3100 ;directory file control block address
line equ $3104 ;current screen line
ldd #0 ;clear line counter
std line
ldd #whatdrive ;get address of message
again jsr display ;display it
ldd #9 ;maximum length of drive number entry
pshs d ;save on stack as P2
ldd #drive ;address of buffer for "Drive ? x"
jsr getrec_ ;get record
puls d ;clean up stack
jsr putnl_ ;new line
ldd drive+8 ;get character back
cmpa #'0 ;check if drive 0 wanted
bne not0 ;check next
ldd #drive0 ;get drive 0 address
jmp opendir ;go and open the file
not0 cmpa #'1 ;check if drive 1 wanted
lbne driverr ;incorrect drive number
ldd #drive1 ;get drive 1 address
opendir jsr diropenf_ ;open directory file
lbeq direrr ;could not open file
std dirblock ;save file control block address
loop
ldd line ;get current line
addd #1 ;add 1 to it
std line ;save it
cmpd #24 ;check if on line 24 yet
if eq ;if 24 lines
ldd #1 ;wait for <return>
pshs d
ldd #buffer
jsr getrec_
puls d
ldd #0 ;clear line count
std line
endif
ldd #buffer ;get P2, address where entry will go
pshs d ;save it on stack
ldd dirblock ;get file control block address
jsr dirreadf_ ;get a directory entry
puls d ;clean up stack
ldd #buffer ;get address of directory entry
jsr display ;put it on screen
jsr putnl_ ;crlf on screen
ldd dirblock ;get file control block address
jsr errorf_ ;check if end of file
cmpd #2 ;check if end of file
until eq ;until end of file
ldd dirblock ;get address of file control block
jsr dirclose_ ;close file
leave ldd #1 ;arbitrary length
pshs d ;P2
ldd #buffer ;address of buffer
jsr getrec_ ;get <return>
puls d ;clean stack
jmp out ;quit
display tfr d,x ;put P1 in X
loop
ldb ,x+ ;get character
quif eq
pshs x ;save address
jsr putchar_ ;display character
puls x ;restore address
endloop
rts
direrr jsr putnl_ ;crlf to screen
ldd #direrrmsg ;get address of disk error message
jsr display ;put message on screen
jmp leave ;get <return> and exit
driverr jsr putnl_ ;crlf to screen
ldd #drivemsg ;get address of drive number error message
jsr display ;put message on screen
ldd #askagain ;get address of string to reprint
jmp again ;do it again
;all data needed by program
whatdrive fcb 12
fcc "Directory program"
fcb 13
fcc "From Commodore Business Machines"
fcb 13
fcc "By Eric Brandon"
askagain fcb 13,13
fcc "Drive ? "
fcb 0
drive0 fcc "disk/0"
fcb 0
drive1 fcc "disk/1"
fcb 0
direrrmsg fcc "Cannot open directory"
fcb 13,0
drivemsg fcc "Incorrect drive number. Use 0 or 1"
fcb 0